package com.letwal.cmcvnd.aviewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.letwal.cmcvnd.base.BaseViewModel
import com.letwal.cmcvnd.anetwork.ApiUserReposity
import com.letwal.cmcvnd.data.ReqBase

class AppViewModel : BaseViewModel() {


    private val mGetIpInfoLiveData = MutableLiveData<ReqBase>()

    val onGetIpInfoLiveData =
        Transformations.switchMap(mGetIpInfoLiveData) { query ->
            ApiUserReposity.getIpInfo(this, query)
        }

    fun getIpInfo(reqBase: ReqBase) {
        mGetIpInfoLiveData.value = reqBase
    }

    //////////////////////////////////////////

    //////////////////////////////////////////
    private val mAppVersionLiveData = MutableLiveData<ReqBase>()

    val onAppVersionLiveData =
        Transformations.switchMap(mAppVersionLiveData) { query ->
            ApiUserReposity.appVersion(this, query)
        }

    fun appVersion(reqBase: ReqBase) {
        mAppVersionLiveData.value = reqBase
    }
}